package pl.wroc.uni.ii.puzzle.game;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Paint.Style;

public class FlashBoard extends Board {
	
	public FlashBoard(Game game, int level) {
		super(game, level);
		game.playSound(Game.LEVEL_COMPLETE_SOUND_ID);
	}

	@Override
	public void draw(Canvas canvas) {
		drawBackground(canvas);
		drawMessage(canvas);
	}

	private void drawBackground(Canvas canvas) {
		Paint paint = new Paint();
		int left = 0;
		int top = 0;
		canvas.drawBitmap(bitmap, left, top, paint);
	}

	private void drawMessage(Canvas canvas) {
		Paint paint = new Paint();
		String message = "Level "+Integer.toString(currentLevel/2+1)+" Complete";
		int left = 50;
		int top = 220;
		paint.setTextSize(28);

		int span = 10;
		Rect bounds = new Rect();
		int start = 0;
		int end = message.length();
		paint.getTextBounds(message, start, end, bounds);
		paint.setStyle(Style.FILL);
		paint.setAlpha(100);
		bounds.offset(left, top);
		bounds.inset(-span, -span);
		canvas.drawRect(bounds, paint);

		paint.setColor(Color.WHITE);
		paint.setAntiAlias(true);
		paint.setStyle(Style.STROKE);
		canvas.drawText(message, left, top, paint);
	}

	@Override
	public void clickCellFromCoordinates(float x, float y) {
		game.startNewLevel();
	}

	@Override
	public void swipeBottomToTopCellFromCoordinates(float x, float y) {
		game.startNewLevel();
	}

	@Override
	public void swipeLeftToRightCellFromCoordinates(float x, float y) {
		game.startNewLevel();		
	}

	@Override
	public void swipeRightToLeftCellFromCoordinates(float x, float y) {
		game.startNewLevel();
	}

	@Override
	public void swipeTopToBottomCellFromCoordinates(float x, float y) {
		game.startNewLevel();
	}

}
